//编写函数，接受一个forward_list<string>和两个string共三个参数。函数应在链表中查找第一个string
//并将第二个string插入到紧接着第一个string之后的位置。若第一个string未在链表中，则将第二个string插入到链表末尾。
#include<iostream>
#include<fstream>
#include<string>
#include<list>
#include<vector>
#include<sstream>
#include<deque>
#include<forward_list>
using namespace std;
void func(forward_list<string> &a, string &b, string &c)
{
	auto bef_it = a.before_begin();
	auto it = a.begin();
	bool index = false;
	while (it != a.end()) {
		if (*it == b) {
			it=a.insert_after(it,c);
			bef_it++;
			bef_it++;
			index = true;
		}
		else { it++; bef_it++; }
	}
	if (index == false)
	{
		a.insert_after(bef_it, c);
	}
}
int main()
{
	forward_list<string>for_str = {"I","love","you","my","baby"};
	string str1 = "love";
	string str2 = "guy";
	func(for_str, str1, str2);
	for (auto it : for_str)
	{
		cout << it << endl;
	}
	
}